package com.example.everying.service.user.impl;/*
 * 项目名称: everything
 * 文件名: UserBindRelServiceImpl
 * 作者: 张泽阳
 * 日期: 2025/7/30
 * 描述:
 */

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.everying.mapper.user.UserBindRelMapper;
import com.example.everying.model.entity.user.UserBindRel;
import com.example.everying.service.user.UserBindRelService;
import org.springframework.stereotype.Service;

@Service
public class UserBindRelServiceImpl extends ServiceImpl<UserBindRelMapper, UserBindRel> implements UserBindRelService {
    @Override
    public UserBindRel getByUnionId(String unionId) {
//        LambdaQueryWrapper<UserBindRel> queryWrapper = new LambdaQueryWrapper<>();
//        queryWrapper.eq(UserBindRel::getUnionId, unionId);
//        return getOne(queryWrapper);
        return baseMapper.getByUnionId(unionId);
    }

    @Override
    public boolean deleteByUserId(String userId) {

        LambdaUpdateWrapper<UserBindRel> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(UserBindRel::getUserId, userId);
        updateWrapper.set(UserBindRel::getIsDelete, 1);
        return update(updateWrapper);
    }
    @Override
    public UserBindRel getByPhone(String phone) {
        LambdaQueryWrapper<UserBindRel> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(UserBindRel::getPhone, phone);
        queryWrapper.eq(UserBindRel::getIsDelete, 0);
        return getOne(queryWrapper);
    }
}
